package com.eshop.we.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.eshop.we.school.dto.SchoolDto;
import com.eshop.we.school.entity.School;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 学校 Mapper 接口
 * </p>
 *
 * @author anonymity
 * @since 2018-07-06
 */
@Mapper
@Component
public interface SchoolMapper extends BaseMapper<School> {

    @Select("<script>"
            + "SELECT "
            + "*  , (select name from area where pro_id=area_id ) as proName , (select name from area where city_id=area_id ) as cityName ,(select name from area where cou_id=area_id ) as couName "
            +" from school"
            + "<if test='schoolName!=null '>"
            + "WHERE  schoolName like CONCAT(CONCAT('%', #{schoolName}), '%')"
            + "</if>"+
            "</script>")
   List<SchoolDto> selectSchoolPage(Page<SchoolDto> page,@Param("schoolName") String schoolName);

}
